package com.ruoyi.fjtseac.controller;


import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.fjtseac.domain.dto.TypeDto;
import com.ruoyi.fjtseac.service.TypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

/**
 * 类型Controller
 *
 * @author icyrain11
 * @date 2023-06-29
 */
@Controller
@RequestMapping("/type")
@Api(tags={"类型接口"})
public class TypeController {

    private TypeService typeService;

    @Autowired
    public TypeController(TypeService typeService) {
        this.typeService = typeService;
    }


    @PreAuthorize("@ss.hasPermi('fjtseac:type:add')")
    @PostMapping("/addType")
    @ApiOperation(value = "增加刊目类型")
    @ResponseBody
    public AjaxResult addType(@RequestBody TypeDto typeDto) {
        return typeService.addType(typeDto);
    }


    @PreAuthorize("@ss.hasPermi('fjtseac:type:remove')")
    @DeleteMapping("/deleteType")
    @ApiOperation(value = "删除刊目类型")
    @ResponseBody
    public AjaxResult deleteType(@ApiParam(value = "类型id", required = true) @RequestParam Integer typeId) {
        return typeService.deleteType(typeId);
    }

    @PreAuthorize("@ss.hasPermi('fjtseac:type:update')")
    @PutMapping("/updateType")
    @ApiOperation(value = "修改刊目类型")
    @ResponseBody
    public AjaxResult updateType(@RequestBody TypeDto typeDto) {
        return typeService.updateType(typeDto);
    }

    @GetMapping("/selectAllType")
    @ApiOperation(value = "查询刊目类型")
    @ResponseBody
    public AjaxResult selectAllType() {
        return typeService.selectAllType();
    }

}

